package com.fankui.serviceoss.controller;

import com.fankui.commonutils.R;
import com.fankui.serviceoss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName OssController
 * Description TODO
 * Date 2023/11/23 18:32
 *
 * @Author 范奎
 * @Since JDK 11
 */
@Api(description = "阿里云OSS")
@RestController
@RequestMapping("/ossservice")
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "上传头像")
    @PostMapping("upload")
    public R uploadOssFile(@ApiParam(name = "file", value = "文件上传对象") MultipartFile file) {
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url", url);
    }
}
